#ifndef LOGINUI_H
#define LOGINUI_H

#include <QWidget>
#include <QLineEdit>
#include <QPushButton>
#include <QLabel>
#include <QVBoxLayout>
#include <QHBoxLayout>

class LoginUI : public QWidget
{
    Q_OBJECT
public:
    explicit LoginUI(QWidget *parent = nullptr);

    // 获取输入内容
    QString getUsername() const;
    QString getPassword() const;
    QString getConfirmPassword() const;

    // 设置UI状态
    void setLoginMode(bool isLoginMode);
    void setButtonsEnabled(bool enabled);
    void setLoginButtonText(const QString& text);
    void setRegisterButtonText(const QString& text);
    void clearInputs();

    // 控件获取接口
    QPushButton* loginButton() const { return m_loginBtn; }
    QPushButton* registerButton() const { return m_regBtn; }
    QPushButton* closeButton() const { return m_closeBtn; }

signals:
    // 通知外部鼠标拖动事件
    void mouseDragged(const QPoint& delta);

protected:
    // 鼠标事件重写，实现窗口拖动
    void mousePressEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;

private:
    void initUI();  // 初始化界面组件

    // UI组件
    QLineEdit* m_userEdit;
    QLineEdit* m_pwdEdit;
    QLineEdit* m_confirmPwdEdit;
    QPushButton* m_loginBtn;
    QPushButton* m_regBtn;
    QPushButton* m_closeBtn;

    // 拖动相关
    bool m_isDragging;
    QPoint m_dragPosition;
};

#endif // LOGINUI_H
